﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Interface_Tier;
using Transfer_Object_Tier;

namespace eSolution_HRMSS.Winforms.QuaTrinhLamViec
{
    public partial class FR_TaiNanLaoDong : DevExpress.XtraEditors.XtraForm
    {
        IHRM_PROCESS_ACCIDENTData _IHRM_PROCESS_ACCIDENTData;
        ICommonCode _icommon;
        eSolution_HRMSS.HRMSS_Ultil util = new HRMSS_Ultil();
        Guid currentId;
        Guid new_id;
        bool isUpdate = false;
         public FR_TaiNanLaoDong(bool _isUpdate)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
        }

         public FR_TaiNanLaoDong(bool _isUpdate, Guid _currentId)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
            currentId = _currentId;
        }

        private void labelControl1_Click(object sender, EventArgs e)
        {

        }

        private void FR_TaiNanLaoDong_Load(object sender, EventArgs e)
        {
            _IHRM_PROCESS_ACCIDENTData = (IHRM_PROCESS_ACCIDENTData)Activator.GetObject(typeof(IHRM_PROCESS_ACCIDENTData), util.ChuoiPROCESS_ACCIDENTData);
            _icommon = (ICommonCode)Activator.GetObject(typeof(ICommonCode), util.Chuoicommon);
        }
        private HRM_PROCESS_ACCIDENT lay_thong_tin()
        {
            string veviec = txtveviec.Text;
            string lydo = txtlydo.Text;
            string diadiem = txtdiadiem.Text;
            string mota = txtmota.Text;
            string thiethai = txtthiethai.Text;
            string thuongtat = txtthuongtat.Text;
            string boithuong = txtboithuong.Text;
            string ghichu = txtghichu.Text;
            DateTime ngayxayra = dtngayxayra.DateTime;

            HRM_PROCESS_ACCIDENT accident = new HRM_PROCESS_ACCIDENT();
            accident.AccidentName = veviec;
            accident.Reason = lydo;
            accident.Location = diadiem;
            accident.Description = mota;
            accident.Damage = thiethai;
            accident.Injury = thuongtat;
            accident.Allowance = boithuong;
            accident.Note = ghichu;
            accident.DateOccured = ngayxayra;
            return accident;
        }
        private void load_info()
        {
            DataTable dt = _IHRM_PROCESS_ACCIDENTData.HRM_PROCESS_ACCIDENT_Get(currentId).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                txtveviec.Text = dr["AccidentName"].ToString();
                txtlydo.Text = dr["Reason"].ToString();
                txtdiadiem.Text = dr["Location"].ToString();
                txtmota.Text = dr["Description"].ToString();
                txtthiethai.Text = dr["Damage"].ToString();
                txtthuongtat.Text = dr["Injury"].ToString();
                txtboithuong.Text = dr["Allowance"].ToString();
                txtghichu.Text = dr["Note"].ToString();
                dtngayxayra.DateTime = DateTime.Parse(dr["DateOccured"].ToString());
            }
        }
    }
}